<!DOCTYPE html>
<html class="x-admin-sm">

    <head>
        <meta charset="UTF-8">
        <title>屏幕内容显示设置</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!--        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />-->
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="./css/xadmin.css">
<!--        <script src="./lib/layui/layui.js" charset="utf-8"></script>-->
<!--        <link rel="stylesheet" href="lib/layui/css/layui.css">-->
        <link rel="stylesheet" href="lib/layui2/css/layui.css">
        <script src="lib/layui2/layui.js"></script>
        <script type="text/javascript" src="./js/xadmin.js"></script>
        <script type="text/javascript" src="./js/jquery.min.js"></script>
        <script type="text/javascript" src="./data/sensor.js"></script>
<!--        <script src="./js/vue2.js"></script>-->
        <!-- 开发环境版本，包含了有帮助的命令行警告 -->
        <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->

    </head>

    <body  >

        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">系统设置</a>
                <a>
                    <cite>屏幕内容显示设置</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">

                        <div class="layui-card-body ">
                                <h3 style="font-weight: bold;">显示曲线的气体: 左侧候选项,右侧为已选项</h3>
                                <div id="test7" class="demo-transfer"></div>
                                <div class="layui-btn-container">
                                    <button type="button" class="layui-btn" lay-demotransferactive="getData">保存设置</button>
                                    <!--                            <button type="button" class="layui-btn" lay-demotransferactive="reload">重载实例</button>-->
                                </div>
                        </div>
                    </div>



                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <h3 style="font-weight: bold;">显示风速和风向:</h3>
                            启用：<input type="checkbox" id="show_wind"  onchange="btn_Show_Wind()" />
                        </div>
                    </div>

                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <h3 style="font-weight: bold;">屏幕数据刷新频率:</h3>
                            分钟：<input type="text" id="input_refresh_led_FS"  onblur="btn_refresh_led_FS()" />
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </body>
    <script type="text/html" id="toolbarMenu">
        <div class = "layui-btn-container" >
<!--            <button class = "layui-btn layui-btn-sm" lay-event = "getCheckData" > 获取选中行数据 </button>-->
<!--            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button >-->
<!--            <button class = "layui-btn layui-btn-sm" lay-event = "addSensor" onclick="xadmin.open('添加设备','./sensor-add.html',600,400)" ><i class="layui-icon"></i> 新增传感器</button>-->
        </div >
    </script>
    <script type="text/html" id="toolbarDemo">


        <div class = "layui-btn-container" >

<!--            <button class = "layui-btn layui-btn-sm" lay-event = "getCheckData" > 获取选中行数据 </button>-->
<!--            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button > -->
<!--            <button class = "layui-btn layui-btn-sm" lay-event = "isAll" > 验证是否全选</button>-->
            <button class = "layui-btn layui-btn-sm"   lay-event = "openDefault" > 开启关闭默认</button>
            <button class="layui-btn layui-btn-sm"  lay-event = "changeDeviceType" > 切换类型</button>
            <button class = "layui-btn layui-btn-danger"   lay-event = "delete" > 删除</button>

        </div >
    </script>


<!--    <script type="text/html" id="switchTpl">-->
<!--        &lt;!&ndash; 这里的checked的状态只是演示 &ndash;&gt;-->
<!--        <input type = "checkbox" name = "sex" value = "{{d.id}}" lay-skin = "switch"lay-text = "女|男" lay-filter = "sexDemo" {{ d.id == 10003 ? 'checked': ''}} >-->
<!--    </script>-->
<!--    <script>layui.use('laydate',-->
<!--        function() {-->
<!--            var laydate = layui.laydate;-->

<!--            //执行一个laydate实例-->
<!--            laydate.render({-->
<!--                elem: '#start' //指定元素-->
<!--            });-->

<!--            //执行一个laydate实例-->
<!--            laydate.render({-->
<!--                elem: '#end' //指定元素-->
<!--            });-->

<!--        });</script>-->

    <script>
        $(function () {
            initShowWind();
            initrefresh_led_FS();
        })
        //获取矿名称
        function  initCheckInfo() {
            let postData={"appkey":"ledShowChartList"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null){
                    return settingsInfo.appval;
                }
            }
        }

        layui.use(['transfer', 'layer', 'util'], function(){
            var $ = layui.$
                ,transfer = layui.transfer
                ,layer = layui.layer
                ,util = layui.util;
            //模拟数据
            var data1 = [
                {"value": "CH4", "title": "CH4"}
                ,{"value": "CO2", "title": "CO2"}
                ,{"value": "CO", "title": "CO"}
                ,{"value": "O2", "title": "O2"}
                ,{"value": "T", "title": "温度"}
                ,{"value": "H", "title": "湿度"}
            ]
            //基础效果
            transfer.render({
                elem: '#test1'
                ,data: data1
            })
            let normalData=initCheckInfo();
            if(normalData==null)
            {
                normalData=[];
            }else{
                normalData=normalData.split(",");
            }
            //debugger;
            //实例调用
            transfer.render({
                elem: '#test7'
                ,title: ['候选列表', '已选列表']  //自定义标题
                ,data: data1
                ,id: 'key123' //定义唯一索引
                ,value: normalData//["CH4","CO2"]
            })
            //批量办法定事件
            util.event('lay-demoTransferActive', {
                getData: function(othis){
                    var getData = transfer.getData('key123'); //获取右侧数据
                   // layer.alert(JSON.stringify(getData));

                    let showGasChartList='';
                    for (let i=0;i<getData.length;i++){
                        showGasChartList+=getData[i].value+",";
                    }
                    showGasChartList=showGasChartList.substr(0,showGasChartList.length-1);
                    console.log(showGasChartList);

                    var inputText=showGasChartList;
                    let inputId="ledShowChartList";
                    let postSData={"appkey":inputId,"appval":inputText,"note":"LED显示折线图的控制"};
                    let resultCount=sensorServer.updateSettingsInfo(postSData);
                    if(resultCount==1) {
                        layer.msg("保存成功！");
                    }else{
                        layer.msg("保存失败！");
                    }
                }
                ,reload:function(){
                    //实例重载
                    // transfer.reload('key123', {
                    //     title: ['候选列表', '已选列表']
                    //     ,value: ['2', '5', '9']
                    //     ,showSearch: true
                    // })
                }
            });

        });


       // layui.use('table',
       //    function() {
        //       var table = layui.table;
        //
        //         //监听单元格编辑
        //         table.on('edit(test)',
        //             function(obj) {
        //                 var value = obj.value //得到修改后的值
        //                     ,
        //                     data = obj.data //得到所在行所有键值
        //                     ,
        //                     field = obj.field; //得到字段
        //                 layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改为：' + value);
        //             });

                //头工具栏事件
           //      table.on('toolbar(test)',
           //          function(obj) {
           //              var checkStatus = table.checkStatus(obj.config.id);
           //              switch (obj.event) {
           //                  case 'getCheckData':
           //                      var data = checkStatus.data;
           //                      layer.alert(JSON.stringify(data));
           //                      break;
           //                  case 'getCheckLength':
           //                      var data = checkStatus.data;
           //                      layer.msg('选中了：' + data.length + ' 个');
           //                      break;
           //                  case 'isAll':
           //                      layer.msg(checkStatus.isAll ? '全选': '未全选');
           //                      break;
           //
           //              };
           //          });
           // });



    </script>

    <script type="text/javascript">
        // var app = new Vue({
        //     el: '#app',
        //     data:{
        //         warning_device_fault:"",
        //         warning_device_fault_jiange:"",
        //         warning_overrun_gas:"",
        //         warning_overrun_gas_jiange:"",
        //     }
        // })
        // function initSensorList(dataSensor){
        //     layui.use('table', function () {
        //         var table = layui.table;
        //         //第一个实例
        //         table.render({
        //             elem: '#demo'
        //             ,
        //             height: 480
        //             , data: dataSensor,
        //             page: false //开启分页
        //             ,limit: 100,
        //            // toolbar: '#toolbarMenu',
        //             cols: [[ //表头
        //                  {field: 'pid', title: '编号', width: 80, sort: true, fixed: 'left',hide:true}
        //                 , {field: 'ch4', title: '甲烷最大警值(%)', width: 200, edit: 'text'}
        //                 , {field: 'co2', title: '二氧化碳最大警值(%)', width: 200, edit: 'text'}
        //                 , {field: 'co', title: '一氧化碳最大警值(ppm)', width: 200, edit: 'text'}
        //                 , {field: 'temperature', title: '温度最大值(℃)', width: 200, edit: 'text'}
        //                 , {field: 'o2', title: '氧气最低值(%)', width: 200, edit: 'text'}
        //                 , {field: 'humidity', title: '湿度最大值（RH%）', width: 200, edit: 'text'}
        //             ]]
        //             ,loading:true,
        //             done:function (res, curr, count) {
        //                 $("[data-field='smokenormal']").children().each(function(){
        //                     if($(this).text()!=''){
        //                         $(this).text("正常")
        //                     }
        //                         // else if($(this).text()=='0'){
        //                     //     $(this).text("正常")
        //                     // }
        //                    // $(this).text("正常")
        //                 });
        //             }
        //         });
        //
        //         //监听单元格编辑
        //         table.on('edit(test_table)',
        //             function (obj) {
        //                 var value = obj.value //得到修改后的值
        //                     ,
        //                     data = obj.data //得到所在行所有键值
        //                     ,
        //                     field = obj.field; //得到字段
        //                 //layer.msg('[ID: ' + data.pid + '] ' + field + ' 字段更改为：' + value);
        //                 layer.msg(field + ' 字段更改为：' + value);
        //                 var jsonResult = sensorServer.updateMaxSetting(obj.data);
        //                 console.log(jsonResult);
        //             });
        //
        //         //监听行单击事件（双击事件为：rowDouble）
        //         //table.on('row(test_table)', function(obj){
        //         // var data = obj.data;
        //         // layer.alert(JSON.stringify(data), {
        //         //     title: '当前行数据：'
        //         // });
        //
        //         //标注选中样式
        //         //obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        //         //  });
        //
        //         //头工具栏事件
        //         table.on('toolbar(toolbarDemo)', function(obj) {
        //             var checkStatus = table.checkStatus(obj.config.pid);
        //             switch (obj.event) {
        //                 case 'delete':
        //                     layer.msg('data:'+obj.data.pid);
        //                     //del(obj);
        //                     break;
        //             };
        //         });
        //         //列里的工具栏
        //         table.on('tool(test_table)',
        //             function(obj) {
        //                 //var checkStatus = table.checkStatus(obj.config.pid);
        //                 // switch (obj.event) {
        //                 //     case 'delete':
        //                 //         layer.msg('data:'+obj.data.pid);
        //                 //         del(obj);
        //                 //         break;
        //                 //     case 'openDefault':
        //                 //         layer.msg('data:'+obj.data.pid);
        //                 //         openDefaultClick(obj);
        //                 //         break;
        //                 //     case 'changeDeviceType':
        //                 //             layer.msg('data:'+obj.data.pid);
        //                 //             changeDeviceType(obj);
        //                 //             break;
        //                 // };
        //             });
        //     });
        // }
        //
        // function getData(){
        //      dataSensor=sensorServer.getMaxSetting({"page":1,"rows":1000});
        //      return dataSensor;
        // }
        // //加载默认数据
        // $(function () {
        //     initPageSetInfo();
        //     var  dataSensor=getData();
        //     if (dataSensor!=null&&dataSensor!=undefined){
        //         initSensorList(dataSensor.data);
        //     }else{
        //         layer.msg('加载失败！!',{icon:1,time:1000});
        //     }
        // })

        function sensorInfo(pid,deviceId){
            this.pid=pid;
            this.deviceId=deviceId;
        }
        function  del(obj){
            layer.confirm('确认要删除吗？',function(index){
                //发异步删除数据
                //sensorServer.delSensorInfo11(obj.data);
               //  $(obj).parents("tr").remove();
               //  $(obj).remove();
               // layer.msg('已删除!',{icon:1,time:1000});
               // location.reload();
            });
        }
        function  openDefaultClick(obj){

        }

        function  changeDeviceType(obj) {

        }

        function  updateMaxSetting(obj) {

        }

        function  initPageSetInfo() {
            initMineName();
            initDataHomeIndexUrl();
            initCadBackground();
            init_map_home_url();
            init_use_last_data();
            init_phone_send_warning_msg();
            f_device_baojing();
            f_morthanCO();

        }

        //获取矿名称
        function  initMineName() {
            let postData={"appkey":"mine_name"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null){
                    $("#input_mine_name").val(settingsInfo.appval);
                }
            }
        }
        //获取设置的首页
        function  initDataHomeIndexUrl() {
            let postData={"appkey":"data_home_url"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null){
                    $("#web_home_url").val(settingsInfo.appval);
                }
            }

        }

        //获取设置的首页
        function  initCadBackground() {
            let postData={"appkey":"cad_background"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null){
                    $("#a_cad_background").attr('href',settingsInfo.appval);
                }
            }
        }

        //设置一张图首页
        function  init_map_home_url() {
            let postData={"appkey":"map_home_url"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null){
                    $("#map_home_url").val(settingsInfo.appval);
                }
            }
        }

        //获取是否开启了默认数据
        function init_use_last_data() {
            let postData={"appkey":"use_last_data"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                    if (settingsInfo.appval == "1") {
                        $("#use_last_data").attr("checked", "checked");
                    }
                }
            }
        }

        function  init_phone_send_warning_msg() {
            let postData={"appkey":"phone_send_warning_msg"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                    if (settingsInfo.appval == "1") {
                        $("#checkbox_phone_msg").attr("checked", "checked");
                    }
                }
            }
        }

        //设置报警规则显示
        function f_device_baojing() {
            let postData={"appkey":"warning_device_fault"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                    app.warning_device_fault=settingsInfo.appval;
                }
            }
            if(2==2){
                let postData={"appkey":"warning_device_fault_jiange"};
                let settingsInfo=sensorServer.getSettingsByAppKey(postData);
                if(settingsInfo!=undefined&&settingsInfo!=null){
                    if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                        app.warning_device_fault_jiange=settingsInfo.appval;
                    }
                }
            }
            if(3==3){
                let postData={"appkey":"warning_overrun_gas"};
                let settingsInfo=sensorServer.getSettingsByAppKey(postData);
                if(settingsInfo!=undefined&&settingsInfo!=null){
                    if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                        app.warning_overrun_gas=settingsInfo.appval;
                    }
                }
            }
            if(4==4){
                let postData={"appkey":"warning_overrun_gas_jiange"};
                let settingsInfo=sensorServer.getSettingsByAppKey(postData);
                if(settingsInfo!=undefined&&settingsInfo!=null){
                    if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                        app.warning_overrun_gas_jiange=settingsInfo.appval;
                    }
                }
            }
        }

        //一氧化碳过滤数据规则
        function f_morthanCO() {
            let postData={"appkey":"more_than_CO"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null){
                    $("#more_than_CO").val(settingsInfo.appval);
                }
            }
            if(2==2){
                let postData={"appkey":"more_than_count"};
                let settingsInfo=sensorServer.getSettingsByAppKey(postData);
                if(settingsInfo!=undefined&&settingsInfo!=null){
                    if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null){
                        $("#more_than_count").val(settingsInfo.appval);
                    }
                }
            }
        }


        function btn_Show_Wind() {
            let appVal=0;
            if($("#show_wind").is(':checked')){
                appVal=1;
            }
            let postSData={"appkey":"show_wind","appval":appVal};
            let resultCount=sensorServer.updateSettingsInfo(postSData);
            if(resultCount==1) {
                layer.msg("保存成功！");
            }else{
                layer.msg("保存失败！");
            }
        }

        function  initShowWind() {
            let postData={"appkey":"show_wind"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                    if (settingsInfo.appval == "1") {
                        $("#show_wind").attr("checked", "checked");
                    }
                }
            }
        }

        function btn_refresh_led_FS() {
            let  appval=$("#input_refresh_led_FS").val();
            if(appval==""||appval=="0"){
                appval=1;
            }
            let postSData={"appkey":"refresh_led_FS","appval":appval,"note":"LED屏幕刷新频率控制-分钟"};
            let resultCount=sensorServer.updateSettingsInfo(postSData);
            if(resultCount==1) {
                layer.msg("保存成功！");
            }else{
                layer.msg("保存失败！");
            }
        }
        function  initrefresh_led_FS() {
            let postData={"appkey":"refresh_led_FS"};
            let settingsInfo=sensorServer.getSettingsByAppKey(postData);
            if(settingsInfo!=undefined&&settingsInfo!=null){
                if(settingsInfo.appval!=undefined&&settingsInfo.appval!=null) {
                    $("#input_refresh_led_FS").val(settingsInfo.appval);
                }
            }
        }
    </script>



</html>
